Skip to content

feat: add blob attachment type for inline base64 data#731

Open
MackinnonBuck wants to merge 2 commits intomainfrom
inline-data-attachments
Open

feat: add blob attachment type for inline base64 data#731
MackinnonBuck wants to merge 2 commits intomainfrom
inline-data-attachments

Conversation

@MackinnonBuck
Copy link
Collaborator

@MackinnonBuck MackinnonBuck commented Mar 9, 2026

Summary

Add support for the new blob attachment type, which allows sending base64-encoded content (e.g. images, screenshots) directly to Copilot sessions without writing to disk first.

This complements the existing file attachment type. While file attachments require a path on disk, blob attachments accept inline base64 data — useful when images are already in memory (screenshots, API responses, generated images).

Changes

Hand-written types

  • Node.js (nodejs/src/types.ts): Added type: "blob" variant to the MessageOptions.attachments union
  • Python (python/copilot/types.py): Added BlobAttachment TypedDict with type, data, mimeType, displayName fields; updated Attachment union

Public API exports

  • Python (python/copilot/__init__.py): Exported BlobAttachment, FileAttachment, DirectoryAttachment, SelectionAttachment, and Attachment from the public API

Documentation

  • docs/features/image-input.md: Added "Quick Start — Blob Attachment" section with examples for all 4 languages; updated overview, tips, and supported formats
  • docs/features/streaming-events.md: Added "blob" to the attachment type list
  • Language READMEs: Added blob attachment examples to Image Support sections
  • test/scenarios/prompts/attachments/README.md: Documented blob attachment format and language-specific syntax

Not included

Related

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Cross-SDK Consistency Review ✅

This PR successfully adds the blob attachment type across all 4 SDK implementations with excellent consistency! The feature is implemented uniformly across Node.js, Python, Go, and .NET.

✅ What's great:

  • ✅ Generated types updated in all 4 SDKs
  • ✅ Manual type definitions added where needed (Node.js types.ts, Python types.py)
  • ✅ Python properly exports BlobAttachment and all attachment types from __init__.py
  • ✅ Comprehensive documentation with examples for all 4 languages
  • ✅ API naming follows proper language conventions (camelCase vs PascalCase)
  • ✅ All READMEs updated consistently

Minor suggestion:

There are a couple of documentation comments that could be updated for completeness (see inline comments), but these are non-blocking polish items. The actual implementation is solid and consistent across all SDKs.

Great work maintaining feature parity! 🎉

Generated by SDK Consistency Review Agent for issue #731 ·

@MackinnonBuck MackinnonBuck force-pushed the inline-data-attachments branch from 75cd246 to 9d9671a Compare March 9, 2026 02:06
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

SDK Consistency Review: Critical Issues Found ⚠️

Thank you for working on blob attachment support! However, I've identified cross-SDK consistency issues that need to be addressed before this PR can maintain feature parity across all four SDK implementations.

❌ Missing Implementation in Go SDK

The Go SDK's generated types in go/generated_session_events.go are missing blob support:

Current state:

type Attachment struct {
    DisplayName *string `json:"displayName,omitempty"`
    Path *string `json:"path,omitempty"`
    Type AttachmentType `json:"type"`
    FilePath *string `json:"filePath,omitempty"`
    // ... other fields for selection, github_reference
    // ❌ Missing: Data and MIMEType fields
}

const (
    Directory       AttachmentType = "directory"
    File            AttachmentType = "file"
    GithubReference AttachmentType = "github_reference"
    Selection       AttachmentType = "selection"
    // ❌ Missing: Blob constant
)

What's needed:

  • Add Data *string and MIMEType *string fields to the Attachment struct
  • Add Blob AttachmentType = "blob" constant

❌ Missing Implementation in .NET SDK

The .NET SDK's generated types in dotnet/src/Generated/SessionEvents.cs are missing blob support:

Current state:

[JsonPolymorphic(TypeDiscriminatorPropertyName = "type", ...)]
[JsonDerivedType(typeof(UserMessageDataAttachmentsItemFile), "file")]
[JsonDerivedType(typeof(UserMessageDataAttachmentsItemDirectory), "directory")]
[JsonDerivedType(typeof(UserMessageDataAttachmentsItemSelection), "selection")]
[JsonDerivedType(typeof(UserMessageDataAttachmentsItemGithubReference), "github_reference")]
// ❌ Missing: JsonDerivedType for blob
public partial class UserMessageDataAttachmentsItem { ... }

// ❌ Missing: UserMessageDataAttachmentsItemBlob class entirely

What's needed:

  • Create UserMessageDataAttachmentsItemBlob class with Data, MimeType, and DisplayName properties
  • Add [JsonDerivedType(typeof(UserMessageDataAttachmentsItemBlob), "blob")] attribute

⚠️ Incomplete Python Generated Types

While the Python SDK has a working implementation via the manual BlobAttachment TypedDict in types.py, the generated types in python/copilot/generated/session_events.py are incomplete:

class AttachmentType(Enum):
    DIRECTORY = "directory"
    FILE = "file"
    GITHUB_REFERENCE = "github_reference"
    SELECTION = "selection"
    # ❌ Missing: BLOB = "blob"

`@dataclass`
class Attachment:
    type: AttachmentType
    # ... existing fields
    # ❌ Missing: data and mime_type fields

🔧 Root Cause

The issue appears to be that the schema used for type generation (session-events.schema.json from @github/copilot) may not have been updated with the blob attachment variant yet, or the type generation script wasn't re-run after the schema update.

📋 Action Items

To bring all SDKs into alignment:

  1. Verify schema is up-to-date: Ensure session-events.schema.json from @github/copilot (referenced in copilot-agent-runtime#4249) includes the blob attachment type
  2. Re-run type generation: Execute npm run generate:session-types in the nodejs/ directory to regenerate all four language SDKs' types
  3. Verify generated output: Confirm that:
    • Go's Attachment struct has Data and MIMEType fields + Blob constant
    • .NET's generated file has UserMessageDataAttachmentsItemBlob class and the corresponding JsonDerivedType
    • Python's generated Attachment dataclass has data and mime_type fields + BLOB enum value

📚 Documentation is Excellent

The documentation updates across all four SDK READMEs and docs/features/image-input.md are comprehensive and show proper examples for all languages—once the generated types are fixed, these examples will work perfectly! ✨


Recommendation: Please update the generated types for Go, .NET, and Python before merging. The manual types in Node.js and Python's types.py are good workarounds, but having consistent generated types across all SDKs is important for long-term maintainability.

Generated by SDK Consistency Review Agent for issue #731 ·

@MackinnonBuck MackinnonBuck force-pushed the inline-data-attachments branch from 9d9671a to 7f62d6c Compare March 9, 2026 02:21
@MackinnonBuck
Copy link
Collaborator Author

CI failures are expected until the runtime PR merges.

Add support for a new 'blob' attachment type that allows sending
base64-encoded content (e.g. images) directly without disk I/O.

Generated types will be updated automatically when the runtime publishes
the new schema to @github/copilot. This commit includes:

- Add blob variant to Node.js and Python hand-written types
- Export attachment types from Python SDK public API
- Update docs: image-input.md, all language READMEs, streaming-events.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MackinnonBuck MackinnonBuck force-pushed the inline-data-attachments branch from 7f62d6c to 7398b25 Compare March 12, 2026 15:19
@github-actions
Copy link
Contributor

✅ Cross-SDK Consistency Review

I've reviewed PR #731 for cross-SDK consistency across all four language implementations (Node.js/TypeScript, Python, Go, and .NET).

Summary: Excellent consistency maintained

This PR successfully adds the blob attachment type to all four SDKs with proper feature parity:

Type Definitions ✅

  • Node.js/TypeScript: Manual type added to MessageOptions.attachments union in nodejs/src/types.ts + generated types updated
  • Python: BlobAttachment TypedDict added to python/copilot/types.py and properly exported in __init__.py + generated types updated
  • Go: Uses generated Attachment struct from generated_session_events.go with Blob AttachmentType constant
  • .NET: UserMessageDataAttachmentsItemBlob class generated in dotnet/src/Generated/SessionEvents.cs

API Consistency ✅

All SDKs expose the same three required/optional fields with appropriate naming conventions:

Field Node/Python Go .NET Required
data data Data Data
mimeType mimeType MIMEType MimeType
displayName displayName DisplayName DisplayName Optional

Documentation ✅

  • Comprehensive examples added to all four language READMEs
  • Detailed feature documentation in docs/features/image-input.md with side-by-side examples
  • Updated docs/features/streaming-events.md to mention blob attachments
  • Test scenario documentation updated in test/scenarios/prompts/attachments/README.md

No consistency issues found 🎉

The implementation properly accounts for language idioms (camelCase in TS/Python dict keys, PascalCase in Go/C# public APIs) while maintaining semantic equivalence across all SDKs.

Generated by SDK Consistency Review Agent for issue #731 ·

@MackinnonBuck MackinnonBuck marked this pull request as ready for review March 12, 2026 16:13
@MackinnonBuck MackinnonBuck requested a review from a team as a code owner March 12, 2026 16:13
Copilot AI review requested due to automatic review settings March 12, 2026 16:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds cross-SDK support for a new "blob" attachment type so callers can send inline base64 content (e.g., images) without writing to disk first, alongside the existing file/directory/selection attachment mechanisms.

Changes:

  • Extended Node and Python attachment type unions to include type: "blob" with base64 data + mimeType.
  • Exported Python attachment-related types from the package public API.
  • Updated docs and scenario documentation with blob-attachment examples across Node/Python/Go/.NET.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/scenarios/prompts/attachments/README.md Documents the blob attachment wire format and language-specific syntax.
python/copilot/types.py Adds BlobAttachment TypedDict and extends the Attachment union.
python/copilot/init.py Re-exports attachment types (Attachment, BlobAttachment, etc.) from the public API.
python/README.md Adds a blob-attachment example to the Image Support section.
nodejs/src/types.ts Extends MessageOptions.attachments union with a "blob" variant.
nodejs/README.md Adds a blob-attachment example to the Image Support section.
go/README.md Adds a blob-attachment example to the Image Support section.
dotnet/README.md Adds blob-attachment example and updates file-attachment snippet to the derived attachment type.
docs/features/streaming-events.md Updates attachment type list to include blob.
docs/features/image-input.md Adds “Quick Start — Blob Attachment” with examples for all four languages and updates guidance.

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

✅ Cross-SDK Consistency Review: PASSED

I've completed a comprehensive review of this PR for cross-language SDK consistency. No issues found — this PR maintains excellent feature parity across all four SDK implementations.

Summary

This PR adds support for the blob attachment type (inline base64-encoded data) to complement the existing file attachment type. The implementation is consistent across all languages.

Verification Results

SDK Implementation Fields README Status
Node.js Hand-written (types.ts) data, mimeType, displayName? ✅ Example added
Python Hand-written (types.py) data, mimeType, displayName ✅ Example added
Go Generated (already on main) Data, MIMEType, DisplayName ✅ Example added
.NET Generated (already on main) Data, MimeType, DisplayName ✅ Example added

Field Naming Consistency

All SDKs expose the same three fields with language-appropriate naming conventions:

  • Type discriminator: "blob" (or copilot.Blob constant in Go)
  • Base64 data: data (camelCase) / Data (PascalCase)
  • MIME type: mimeType (camelCase) / MIMEType / MimeType (PascalCase)
  • Display name (optional): displayName (camelCase) / DisplayName (PascalCase)

Documentation Coverage

✅ All language READMEs updated with blob attachment examples
✅ Comprehensive examples in docs/features/image-input.md for all 4 languages
✅ Event documentation updated in docs/features/streaming-events.md
✅ Test scenario documentation updated

Notes

  • As mentioned in the PR description, Go and .NET generated types were already updated via Update @github/copilot to 1.0.4 #796
  • Python public API exports properly include all attachment types (BlobAttachment, FileAttachment, DirectoryAttachment, SelectionAttachment, Attachment)
  • Examples correctly demonstrate language-specific pointer usage (Go) and type naming (.NET generated classes)

Recommendation: Approve — This PR maintains full cross-SDK feature parity with appropriate language idioms.

Generated by SDK Consistency Review Agent for issue #731 ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants